package com.villaday.idf.custom;

import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.villaday.idf.R;
import com.villaday.idf.base.BaseDialog;


/**
 * 确认 对话框
 */
public class EnvelopeConfirmDialog extends BaseDialog implements View.OnClickListener {

    public static EnvelopeConfirmDialog newInstance(String title, String content, String cancel, String confirm) {
        EnvelopeConfirmDialog dialog = new EnvelopeConfirmDialog();
        Bundle bundle = new Bundle();
        bundle.putString("title", title);
        bundle.putString("content", content);
        bundle.putString("cancel", cancel);
        bundle.putString("confirm", confirm);
        dialog.setArguments(bundle);
        return dialog;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_envelope_confirm, null);
        AlertDialog alertDialog = new AlertDialog.Builder(getActivity())
                .setView(view)
                .create();
        //点击对话框外不可取消
        alertDialog.setCanceledOnTouchOutside(false);
        //进入退出动画
//        alertDialog.getWindow().setWindowAnimations(R.style.animTranslateTop);

        TextView tvTitle = (TextView) view.findViewById(R.id.tv_dialogConfirmTitle);
        TextView tvContent = (TextView) view.findViewById(R.id.tv_dialogConfirmcontent);
        TextView btnCancel = (TextView) view.findViewById(R.id.btn_cancelDialog);
        TextView btnConfirm = (TextView) view.findViewById(R.id.btn_confirmDialog);

        tvTitle.setText(getArguments().getString("title"));
        tvContent.setText(getArguments().getString("content"));
        btnCancel.setText(getArguments().getString("cancel"));
        btnConfirm.setText(getArguments().getString("confirm"));
        btnCancel.setOnClickListener(this);
        btnConfirm.setOnClickListener(this);
        return alertDialog;
    }

    @Override
    public void onClick(View v) {
        onItemClickListener.onItemClick(v);
        dismiss();
    }
}
